<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>智能工具管理系统</title>
    <link rel="stylesheet" href="/layui/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/layui/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layui/layuiadmin/style/login.css" media="all">
    <link rel="shortcut icon" href="/img/favicon2.ico">
    <style>
        .ly-btn{
            display: inline-block;
            height: 38px;
            line-height: 38px;
            padding: 0 18px;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;
        }
        .bgcolor{
            background-color: #1E9FFF;
        }
        #img {
            width: 18px;
            position: absolute;
            right: 10px;
            margin-top: 12px;
            top: 1px;
            text-align: center;
        }
        #img2 {
            width: 18px;
            position: absolute;
            right: 10px;
            margin-top: 12px;
            top: 1px;
            text-align: center;
        }
        #DCDUserLogin{
            display: none;
        }
    </style>
</head>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main" id="MySystemUserLogin">
        <div class="layadmin-user-login-box layadmin-user-login-header">
                    <h2 id="sysname" th:text="智慧仓库管理系统"></h2>
                    <p id="sysmark" th:text="上海智沪"></p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
                <img id="img" onclick="hideShowPsw()"
                     src="/img/ps-v.png">
            </div>
            <div class="layui-form-item">
                <button class="ly-btn layui-btn-fluid bgcolor" lay-submit lay-filter="LAY-user-login-submit" onclick="loginjs()" id="loginBtu">登 录</button>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p id="verText" onclick="changeLoginMode()">© 2024 </p>
    </div>
</div>

<script src="/layui/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="/js/md5.js"></script>
<script type="text/javascript" th:inline="javascript">
    $("body").keydown(function() {
        if (event.keyCode == "13") {//keyCode=13是回车键
            if($("#MySystemUserLogin").is(":hidden")){
                $('#DCD-loginBtu').click();//换成按钮的id即可
            }else{
                $('#loginBtu').click();//换成按钮的id即可
            }

        }
    });
    function loginjs(){
        var name=$('#LAY-user-login-username').val();
        var pass=$('#LAY-user-login-password').val();
        if(name!=null && name != "" && pass!=null && pass!="")
        $.post('login',{username:name,password:hex_md5(encodeURIComponent(name+pass))},function(json){
            if(json.code=="suss"){
                layer.msg('登录成功', {
                    offset: '15px'
                    ,icon: 1
                    ,time: 1000
                }, function(){
                    location.href='index';
                } );
            }else if(json.code=="500"){
                layer.msg('账号已被禁用');
            }else{
                layer.msg('账号密码错误');
            }
        },'json');
    }

    layui.config({
        base: '/layui/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user','layer'], function(){
        var $ = layui.$
            ,setter = layui.setter
            ,admin = layui.admin
            ,form = layui.form
            ,router = layui.router()
            ,search = router.search;
        form.render();
    });

    var demoImg = document.getElementById("img");
    var PWD = document.getElementById("LAY-user-login-password");

    var DCDdemoImg = document.getElementById("img2");
    var DCDPWD = document.getElementById("DCD-LAY-user-login-password");

    function hideShowPsw() {
        if (PWD.type == "password") {
            PWD.type = "text";
            demoImg.src = "/img/ps-n.png"; //图片路径（闭眼图片）
        } else {
            PWD.type = "password";
            demoImg.src = "/img/ps-v.png"; // 图片路径（睁眼图片）

        }
    }
    function hideShowPsw2() {
        if (DCDPWD.type == "password") {
            DCDPWD.type = "text";
            DCDdemoImg.src = "/img/ps-n.png"; //图片路径（闭眼图片）
        } else {
            DCDPWD.type = "password";
            DCDdemoImg.src = "/img/ps-v.png"; // 图片路径（睁眼图片）
        }
    }

    function changeLoginMode(){
        if($("#MySystemUserLogin").is(":hidden")){
            $("#MySystemUserLogin").show();
            $("#DCDUserLogin").hide();
            $("#verText").html("© 2024 ")
        }else{
            $("#MySystemUserLogin").hide();
            $("#DCDUserLogin").show();
            $("#verText").html("© 2024-DCD ")
        }
    }
</script>
</body>
</html>
